package com.app.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.app.R;
import com.app.http.HttpDataApi;


public abstract class ActivityBaseMenuText extends ActivityBase implements HttpDataApi.OnRequestCallback {

    protected TextView tvMenu;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void initRootView() {
        mContentView = new LinearLayout(this);
        mContentView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        mContentView.setOrientation(LinearLayout.VERTICAL);
        headView = (RelativeLayout) LayoutInflater.from(this).inflate(R.layout.layout_head_text, null);
        ivBack = (ImageView)headView.findViewById(R.id.ivBack);
        tvTitle = (TextView)headView.findViewById(R.id.tvTitle);
        tvMenu = (TextView)headView.findViewById(R.id.tvMenu);
        ViewGroup.LayoutParams layoutParams = generateDefaultLayoutParams();
        mContentView.addView(headView, layoutParams);
        super.setContentView(mContentView);
        ivBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
                overridePendingTransition(0, R.anim.push_left_out);
            }
        });
    }



    public void setMenuText(CharSequence menuText) {
        tvMenu.setText(menuText);
    }


    public void clearMenu() {
        tvMenu.setVisibility(View.GONE);
    }


    public void setOnMenuClickListener(View.OnClickListener listener) {
        tvMenu.setOnClickListener(listener);
    }

}
